<script type="text/javascript" src="http://code.jquery.com/jquery-1.4.4.min.js"></script>
<script language="javascript">
    
    $(document).ready(function(){
    $("#txtuname").change(function(){
        var usr = $("#txtuname").val();
        if(usr.length >= 4)
        {
            $("#status").html('&nbsp;Checking availability...');
            $.ajax
            ({
                type: "POST",  
                url: "<?php echo $this->baseUrl()."/user/username" ?>",
                data: "txtuname="+ usr,              
                success: function(msgbox)
                {    
              //      $("#status1").html(msgbox);
                    var index_start = msgbox.indexOf("statusCheckEmail") + 18;
                    var index_end = msgbox.indexOf("</div>",index_start);
                    var substr = msgbox.substring(index_start,index_end);
                    $("#status").html(substr);
                    return false;        
                }   
            })
        }
        else
        	{
        	$("#status").html('<font color="red">The username should have at least <strong>4</strong> characters.</font>');
        	$("#txtuname").removeClass('object_ok'); 
        	$("#txtuname").addClass("object_error");
        	}
        })

    })
  
  /*  
    $(document).ready(function(){
    $("#txtuname").change(function(){
            var uname = $("#txtuname").val();
            if(uname.length < 5 || uname == null)
            {
                $("#status").html('<font color="red">Username should have at least <strong>6</strong> character and <strong>not null</strong>.</font>');
            }
            else
            {
                $("#status").html('<img src="http://<?php echo $_SERVER["HTTP_HOST"], $this->baseUrl()?>/public/images/tick.gif" align="center">');
            }
        })
     })
    */
    $(document).ready(function(){
     $("#txtEmail").change(function(){
            var mail = $("#txtEmail").val().match(/^\w+([.-]\w+)*@\w+([.-]\w+)*\.\w{2,8}$/);
            
            if(mail)
            {
                $("#status1").html('<img src="http://<?php echo $_SERVER["HTTP_HOST"], $this->baseUrl()?>/public/images/tick.gif" align="center">');
            }
            else
            {
                $("#status1").html('<font color="red">Email <strong>Invalidate</strong>.</font>');
            }
        })
        })
    
    $(document).ready(function(){
    $("#txtRetypeEmail").change(function(){
            var e_1 = $("#txtEmail").val();
            var e_2= $("#txtRetypeEmail").val();
            if(e_1 == e_2)
            {
                $("#status2").html('<img src="http://<?php echo $_SERVER["HTTP_HOST"], $this->baseUrl()?>/public/images/tick.gif" align="center">');
            }
            else
            {
                $("#status2").html('<font color="red">Retype email not correct');
            }
        })      
    })
     
    $(document).ready(function(){
    $("#txtPassword").change(function(){
            var pass = $("#txtPassword").val();
            if(pass.length >= 5 && pass != null)
            {
                $("#status3").html('<img src="http://<?php echo $_SERVER["HTTP_HOST"], $this->baseUrl()?>/public/images/tick.gif" align="center">');
            }
            else
            {
                $("#status3").html('<font color="red">Password should have at least <strong>5</strong> character and <strong>not null</strong>.</font>');
            }
        })
        })
     
    $(document).ready(function(){
    $("#txtRetypePassword").change(function(){
            var pass1 = $("#txtPassword").val();
            var pass2 = $("#txtRetypePassword").val();
            if(pass1 == pass2)
            {
                $("#status4").html('<img src="http://<?php echo $_SERVER["HTTP_HOST"], $this->baseUrl()?>/public/images/tick.gif" align="center">');
            }
            else
            {
                $("#status4").html('<font color="red">Retype password not correct');
            }
        })      
    }) 
       
</script>





<form id="frmRegister" name="frmRegister" method="post" >
  <table>
    <tr>
      <td><strong>Username: </strong></td>
      <td><label>
        <input type="text" name="txtuname" id="txtuname"  />
        <span>*</span></label>
        <span id="msgbox" style="display:none"></span> </td>
      <td><div id="status"></div></td>  
    </tr>
    
    <tr>
      <td><strong>Email: </strong></td>
      <td><label>
        <input type="text" name="txtEmail" id="txtEmail"  />
        <span>*</span></label>
      <td><div id="status1"></div></td>
    </tr>
    <tr>
      <td><strong>Retype email: </strong></td>
      <td><label>
        <input type="text" name="txtRetypeEmail" id="txtRetypeEmail"  />
        <span>*</span></label>
        <span id="msgbox" style="display:none"></span> </td>
      <td><div id="status2"></div></td>
    </tr>
    <tr><label>
      <td><strong>Password: </strong></td>
      <td>
      <input type="password" name="txtPassword" id="txtPassword" />
            <span>*</span></td></label>
      <td><div id="status3"></div></td>
    </tr>
    <tr>
      <td><strong>Retype password: </strong></td>
      <td><label>
        <input type="password" name="txtRetypePassword" id="txtRetypePassword" />
        <span>*</span></label></td>
      <td><div id="status4"></div></td>
    </tr>
</table>
<p><strong>(* : Required )</strong></p><br />
<p align="left"><input name="btnRegister" type="submit" id="btnRegister" value="Register" /></p>
</form>